package com.example.lianxi222.fragment;

import android.os.Bundle;

import androidx.fragment.app.Fragment;

import android.text.method.HideReturnsTransformationMethod;
import android.text.method.PasswordTransformationMethod;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.example.lianxi222.R;
import com.example.lianxi222.databinding.FragmentMineBinding;
import com.example.mvvm_base.mvvm.db.AppDateBaseUtils;
import com.example.mvvm_base.userbean.UserEntity;
import com.example.mvvm_base.view.BaseSimpleFragment;

import java.util.List;


public class MineFragment extends BaseSimpleFragment<FragmentMineBinding> {
UserEntity.DataBean message;
private boolean flag=false;

    @Override
    protected void initData() {

    }

    @Override
    protected void initView() {
dataBinding.query.setOnClickListener(view -> {
    List<UserEntity.DataBean> dataBeans = AppDateBaseUtils.getInstance().getUserDao().queryUser();
    if(dataBeans!=null&&dataBeans.size()>0){
        message = dataBeans.get(0);
        dataBinding.show.setText(message.toString());
    }
});
dataBinding.delete.setOnClickListener(view -> {
       AppDateBaseUtils.getInstance().getUserDao().deleteUser(message);
});
dataBinding.iv1.setOnClickListener(view -> {
    if(flag){
        dataBinding.et1.setTransformationMethod(HideReturnsTransformationMethod.getInstance());
        flag=false;
    }else{
        dataBinding.et1.setTransformationMethod(PasswordTransformationMethod.getInstance());
        flag=true;
    }
});
    }

    @Override
    protected int getLayoutId() {
        return R.layout.fragment_mine;
    }
}